﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<nwrole.toolbox.sync.entity.SyncEntity>" %>

<!DOCTYPE html>

<html>
<head id="Head1" runat="server">
    <title>Show</title>
    <script src="/Scripts/jquery-1.5.1.js")" type="text/javascript"></script>
</head>
<body>
    <div>
        Id: <%=Model.Id %><br />
        Name: <%=Model.Name %><br />
        Table name: <%=Model.SourceTableName %><br />
        Sync enabled: <%=Model.SyncEnabled%><br />
        Last sync: <%=Model.SyncDat %><br />
    </div>
    Columns:<br />
    <table>
        <tr>
            <th>Column</th>
            <th>Type</th>
            <th>Nullable</th>
            <%--<th>Enabled</th>--%>
        </tr>

<% foreach (var c in Model.Columns)
   { %>        
        <tr>
            <td>
                <%=c.ColumnName %>
            </td>        
            <td>
                <%=c.SourceSqlTypeName %>
            </td>        
            <td>
                <%=(c.SourceSqlTypeNullableBool ? "Ja" : "Nej") %>
            </td>        
            <%--<td>
                <a href="" onclick="return ToggleColumnSyncEnabled(this, <%=c.Id%>);"><%=c.SyncEnabledString%></a>
            </td>        --%>

        </tr>
<% } %>    
    </table>


<script type="text/javascript">
    function ToggleColumnSyncEnabled(obj, colId) {
        $.get('/entity/ToggleColumnSyncEnabled', { id: colId, x: Math.random() }, function (result) {
            if (result.success) {
                if (result.newValue) {
                    $(obj).text('True');
                } else {
                    $(obj).text('False');
                }
            }
            else {
                alert(result.success);
            }
        });
        return false;
    }
</script>
</body>
</html>
